package beans.string;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class StringUtil
{
	/**
	 * String --> InputStream
	 */
	public static InputStream String2InputStream(String str) throws IOException
	{
		ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes());
		return stream;
	}

	/**
	 * InputStream --> String
	 */
	public static String inputStream2String(InputStream is) throws IOException
	{
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		int i = -1;
		while ((i = is.read()) != -1)
		{
			baos.write(i);
		}
		return baos.toString();
	}

	public static void inTurn(String string)
	{
		StringBuffer sBuffer = new StringBuffer();
		for (int i = string.length() - 1; i >= 0; i--)
			sBuffer.append(string.charAt(i));
		System.out.println("StringUtil.inTurn()" + sBuffer.toString());
	}

}
